package Medir.java;

import java.util.Arrays;

public class Fibonacci {
	
@SuppressWarnings("unused")
private static char[] fibonacci;
public static void main(String[] args){	
	
	int N = 10;
	long [] fiboNumbers = new long [N];
	long startTime = System.nanoTime();
	for(int i = 0; i < N; i++)		
	fiboNumbers[i] = (long) fibonacci(i);
	
	long duration = System.nanoTime()- startTime;
	System.out.println(duration /1.0e9);
	
	System.out.println(Arrays.toString(fiboNumbers));
	
	
	startTime = System.nanoTime();
	int n = 20;
	
	long [] fiboNumbers2 = new long [n];
	
	for(int i = 0; i < n; i++)		
		fiboNumbers2[i] = (long) fibonacci(i);
	
	System.out.println(Arrays.toString(fiboNumbers));
	
	System.out.println(duration /1.0e9);
	
			
	}			
		public static long fibonacci(int n)
		{
			if(n <= 1)
				
				return n;
			else
				
			return(n<=1 ? n : fibonacci(n -1) + fibonacci(n-2));
			
		}	
		
	public static long fib(int n)
	{
		
		long numero = 0;
		long anterior = 0;
		
		for(int i = 1; i <= n; i++)
		{
			if(i== 1)
				numero =1;
			else
			{
				
				numero += anterior;
				anterior = numero - anterior;
			}
					
				
		}
		return numero;
		
		
	}
		
}
